using System.Collections.Generic;
using System.ComponentModel;
using System.Runtime.CompilerServices;
using AvaloniaApplication1.Models;

namespace AvaloniaApplication1.ViewModels;

public class DialogTestViewModel:INotifyPropertyChanged
{

    public DeviceCardModel _deviceCardModel { get; }
    private string _deviceName;
    public string DeviceName
    {
        get => _deviceName;
        set=> SetField(ref _deviceName, value);
    }

    public event PropertyChangedEventHandler? PropertyChanged;

    protected virtual void OnPropertyChanged([CallerMemberName] string? propertyName = null)
    {
        PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
    }

    protected bool SetField<T>(ref T field, T value, [CallerMemberName] string? propertyName = null)
    {
        if (EqualityComparer<T>.Default.Equals(field, value)) return false;
        field = value;
        OnPropertyChanged(propertyName);
        return true;
    }
    public DialogTestViewModel(DeviceCardModel  model)
    {
          _deviceCardModel = model;
          DeviceName=_deviceCardModel.DeviceName;
    }
}